clear 

** read in .dta file **

use "${clean}/who_counts_analysis.dta", clear

** Alternate Dichotimzation, 1945-1962 **

** Regressions **

xi: reghdfe MOB did_max Arabic Female *_itTREATED *_itFORMAX, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_MOB_did_BW2_max

xi: reghdfe EDU_YRS did_edu_max Arabic Female *_itTREATEDEDU *_itFORMAX, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_YRS_did_BW2_max

xi: reghdfe Schooling did_edu_max Arabic Female *_itTREATEDEDU *_itFORMAX, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_Schooling_did_BW2_max

xi: reghdfe French_Lit did_edu_max Arabic Female *_itTREATEDEDU *_itFORMAX, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_Lit_did_BW2_max

** Output table **

#delimit ; 
estout m_MOB_did_BW2_max
	   m_Schooling_did_BW2_max
	   m_Lit_did_BW2_max
	   m_YRS_did_BW2_max
       using "${output}/tables/TableA15.tex",
       style(tex) 
       cells(b(star fmt(3)) se(par fmt(3))) 
	   	   varlabels(did_max "Difference in Differences, registration" did_edu_max "Difference in Differences, education"  Female "Female " Arabic "First Language Arabic ")
keep(did_max did_edu_max)
	   stats(controls
	   adminFE
             r2 
             N
			 ymean, fmt(0 0 2 0 3 %9.0gc %9.0gc)
             labels("\hline Controls"
			 "\hline Admin FE"
                   "\hline \(R^2\)" 
                  " \hline N"
				   "Dep. Var. Mean "))
       mlabels(,none) 
       numbers
       collabels(none) 
       starl(* 0.1 ** 0.05 *** 0.01)
	          prehead( 
           \begin{table}[H]
           \caption{Effect of Reforms and European Settlement on Registration and Education Outcomes, Alternate Dichotimzation, 1945-1962}        
           \label{tab:DiD_BW2_max}            
           \centering
           \begin{tabular}{@{\extracolsep{4pt}}l*{@M}{c}@{}} 
           \hline \hline             
		   & \multicolumn{1}{p{3cm}}{\centering Registration} 
		   & \multicolumn{1}{p{3cm}}{\centering Formal Schooling}   
		   & \multicolumn{1}{p{3cm}}{\centering Literacy, Arabic \& French} 
		   & \multicolumn{1}{p{3cm}}{\centering Formal Schooling, Years}                    \\  
       )
       posthead(\hline) 
       prefoot() 
       postfoot(
           \noalign{\smallskip} \hline \hline 
           \end{tabular}
           \medskip
           \begin{minipage}{.9\textwidth}
           \tiny \justify Notes: \( @starlegend \). 
           \\ Fixed Effects and Clustered Robust Standard Errors at Province.
           \end{minipage}        
       \end{table}
       )
       replace;
#delimit cr
